"use strict";

module.exports = (app) => {
  const { STRING, INTEGER, DATE } = app.Sequelize;

  const User = app.model.define("user", {
    id: { type: INTEGER, primaryKey: true, autoIncrement: true },
    name: STRING(30),
    // username 字段设置为唯一且不能为空
    username: { type: STRING(30), allowNull: false, unique: true },
    // password 字段设置为不能为空
    password: { type: STRING(100), allowNull: false },
    // email 字段设置为唯一且不能为空
    email: { type: STRING(100), allowNull: false, unique: true },
    age: INTEGER,
    created_at: DATE,
    updated_at: DATE,
  });

  return User;
};
